#include<iostream>
#include<string>
#include<jsoncpp/json/json.h>
class Request
{
    public:
    Request()
    {

    }
    Request(int x,int y,char oper):_x(x),_y(y),_oper(oper)
    {

    }
    bool Serialize(std::string *out)
    {
        Json::Value root;
        root["x"]=_x;
        root["y"]=_y;
        root["oper"]=_oper;
        Json::FastWriter writer;//工具
        std::string s=writer.write(root);
        *out=s;
        return true;

    }
    void Deserialize(const std::string &in)
    {
        Json::Value root;
        Json::Reader reader;//工具
        bool res=reader.parse(in,root);
        _x=root["x"].asInt();
        _y=root["y"].asInt();
        _oper=root["oper"].asInt();//这里是将数据转成int类型，但是

    }
    void Print()
    {
        std::cout<<_x<<std::endl;
        std::cout<<_y<<std::endl;
        std::cout<<_oper<<std::endl;
    }
    ~Request()
    {

    }
   private:
    int _x;
    int _y;
    char _oper;
};
int main()
{
    // Request req(111, 222, '+');
    // std::string s;
    // req.Serialize(&s);
    // std::cout << s << std::endl;
    std::string s="{\"oper\":43,\"x\":111,\"y\":222}";
    Request req;
    req.Deserialize(s);
    req.Print();
    return 0;
}